package com.yzw.statistics.scheduled;

import com.yzw.statistics.service.EduMemberService;
import com.yzw.statistics.service.EduStatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @Author Yzw
 * @Description TODO
 * @Date 2023/5/17 10:26
 * @Version 1.0
 */
@Component
public class ScheduledTask {

    @Autowired
    EduMemberService eduMemberService;

    /**
     * 每天凌晨0点过一分执行定时
     */
    @Scheduled(cron = "0 1 0 * * ?")
    public void task(){
        // 获取当前日期前一天的日期
        LocalDateTime localDateTime = LocalDateTime.now().minusDays(1);
        String day = localDateTime.toString();
        eduMemberService.countRegisterDay(day);
    }
}
